<?php

/* WORDPRESS TWEAKS */
remove_action ('wp_head', 'rsd_link');
remove_action ('wp_head', 'wlwmanifest_link');
remove_action ('wp_head', 'wp_generator');
remove_action ('wp_head', 'feed_links_extra');
remove_action ('wp_head', 'feed_links');
remove_action ('wp_head', 'index_rel_link');
remove_action ('wp_head', 'parent_post_rel_link');
remove_action ('wp_head', 'start_post_rel_link');
remove_action ('wp_head', 'adjacent_posts_rel_link');


add_filter('widget_text', 'do_shortcode');
add_theme_support( 'post-thumbnails' );
add_theme_support( 'automatic-feed-links' );
if (function_exists('add_theme_support')) { add_theme_support('nav-menus');}
if ( function_exists( 'add_theme_support' ) ){ add_theme_support( 'post-thumbnails' , array( 'post' ));}



/* REGISTER MENU */
register_nav_menu('Primary Navigation', 'Main Navigation');




/* CUSTOM THUMBNAIL SIZES */

/* homepages + blog + portfolio */
add_image_size('home_jquery_one_image', 404, 256, true);
add_image_size('home_jquery_two_image', 436, 270, true);
add_image_size('home_jquery_two_full_image', 840, 270, true);
add_image_size('blog_thumb_image', 538, 218, true);
add_image_size('one_column_gallery_image', 703, 563, true);
add_image_size('posts_shortcode', 65, 65, true);

/* image frames */
add_image_size('large_banner_image', 922, 201, true);
add_image_size('medium_banner_image', 703, 201, true);
add_image_size('small_banner_image', 493, 201, true);
add_image_size('one_half_image', 437, 234, true);
add_image_size('one_half_small_image', 324, 180, true);
add_image_size('one_third_image', 275, 145, true);
add_image_size('one_third_small_image', 202, 113, true);
add_image_size('one_fourth_image', 190, 111, true);
add_image_size('one_fourth_small_image', 135, 76, true);

/* portrait image frames */
add_image_size('portrait_full', 612, 792, true);
add_image_size('portrait_thumb', 275, 355, true);


/* DEFINE EXCERPT LENGTH */
function wpe_excerptlength_archive($length) {
	return 60;
}
function wpe_excerptlength_news($length) {
	return 20;
}
function wpe_excerptmore($more) {
	return '...';
}

function wpe_excerpt($length_callback='', $more_callback='') {
	global $post;
	if(function_exists($length_callback)){
		add_filter('excerpt_length', $length_callback);
	}
	if(function_exists($more_callback)){
		add_filter('excerpt_more', $more_callback);
	}
	$output = get_the_excerpt();
	$output = apply_filters('wptexturize', $output);
	$output = apply_filters('convert_chars', $output);
	$output = '<p>'.$output.'</p>';
	echo $output;
}

/* CUSTOM CONTENT LENGTH FOR BLOG */
function limit_content($content_length = 250, $allowtags = true, $allowedtags = '') {
global $post;
$content = $post->post_content;
$content = apply_filters('the_content', $content);
if (!$allowtags){
	$allowedtags .= '<style>';
	$content = strip_tags($content, $allowedtags);
}
$wordarray = explode(' ', $content, $content_length + 1);
if(count($wordarray) > $content_length) :
	array_pop($wordarray);
	array_push($wordarray, '...');
	$content = implode(' ', $wordarray);
	$content .= "</p>";
endif;

echo $content;
}


?>